#include<iostream>
using namespace std;


namespace Cw
{
	template<class T>
	class SmartPtr
	{
	public:
		// RAII
		SmartPtr(T* ptr)
			:_ptr(ptr)
		{}

		~SmartPtr()
		{
			cout << "delete[] " << _ptr << endl;
			delete[] _ptr;
		}

		T* operator->()
		{
			return _ptr;
		}

		T& operator* ()
		{
			return *_ptr;
		}

		T& operator[] (size_t i)
		{
			return _ptr[i];
		}

	private:
		T* _ptr;
	};
}

